/*
 * Copyright(c) 2018-? the original author[Wien(luweien@aliyun.com)] or authors.
 *
 */
package org.doll.it.base.domain;

import java.util.Date;

import javax.persistence.MappedSuperclass;

import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
* 标准业务DO(Domain/Data Object)基类，包含所有基本属性
* 
* @author Wien(luweien@aliyun.com)
*
*/
@Data
@EqualsAndHashCode(callSuper = true)
@MappedSuperclass
public class DollDO extends BaseDO {

	private static final long serialVersionUID = 4171654629593773998L;

	/**
	 * 创建人
	 */
	@CreatedBy
	protected Long createdBy;

	/**
	 * 创建时间
	 */
	@CreatedDate
	protected Date createdDate;

	/**
	 * 修改人
	 */
	@LastModifiedBy
	protected Long lastModifiedBy;

	/**
	 * 最后修改时间
	 */
	@LastModifiedDate
	protected Date lastModifiedDate;

	/**
	 * 是否新建：
	 * 1，当id为空时
	 * 2，当创建人 或者 创建时间为空时
	 */
	@Override
	public boolean isNew() {
		return (id == null || (createdBy == null && createdDate == null));
	}

}
